using DNFImagePacks2Manager.QuickTool.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System.Collections.Generic;

namespace DNFImagePacks2Manager.Controls
{
    public sealed partial class MultiSelectionDialog : UserControl
    {
        public MultiSelectionDialog()
        {
            InitializeComponent();
        }

        public IEnumerable<ReplaceImageIndex> ItemsSource
        {
            get => (IEnumerable<ReplaceImageIndex>)GetValue(ItemsSourceProperty);
            set => SetValue(ItemsSourceProperty, value);
        }

        public static readonly DependencyProperty ItemsSourceProperty =
            DependencyProperty.Register("ItemsSource", typeof(IEnumerable<ReplaceImageIndex>), typeof(MultiSelectionDialog), new PropertyMetadata(null, OnItemsSourceChanged));

        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is MultiSelectionDialog control)
            {
                control.ListViewControl.ItemsSource = e.NewValue;
            }
        }

        public IEnumerable<ReplaceImageIndex> GetUpdatedItems()
        {
            return ItemsSource;
        }
    }
}
